﻿@{
    ViewData["Title"] = "阅卷申请";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-top: 10px;
        }

        .dSearch .form-control {
            display: inline-block;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }

        #tabData label {
            width: 20px;
            height: 20px;
        }
    </style>

}
<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>阅卷申请审核</h5>
                    <div class="ibox-tools">
                        <a class="btn btn-primary btn-circle btn-outline" title="刷新" href="javascript:location.href=location.href;" style="margin-top: -7px;"><i class=" fa fa-refresh"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div id="toolbar" class="dSearch">
                        <asp:DropDownList ID="ddlState" runat="server" CssClass="form-control" Style="margin-top: 10px;" Width="100" AutoPostBack="True" OnSelectedIndexChanged="ddlState_SelectedIndexChanged">
                            <asp:ListItem Value="" Text="全部"></asp:ListItem>
                            <asp:ListItem Value="0" Text="待审核"></asp:ListItem>
                            <asp:ListItem Value="1" Text="已通过"></asp:ListItem>
                            <asp:ListItem Value="2" Text="不通过"></asp:ListItem>
                            <asp:ListItem Value="3" Text="已过期"></asp:ListItem>
                        </asp:DropDownList>
                        <a class="btn btn-primary btn-sm" style="margin-top: -2px; <%=(State!=" "&&State!=" 0")?"display:none": "" %>" onclick="ApprovalAll()">批量审核</a>
                        <div class="text-danger" style="font-size: 14px; position: absolute; margin-top: -25px; margin-left: 190px"><i class="fa fa-hand-o-right"></i>&nbsp;提示：双击行可查看该档案的详细信息！</div>
                    </div>
                    <table id="tabData" class="table table-bordered" style="min-width: 1400px; width: 100%;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>档案编号</th>
                                <th>天数</th>
                                <th>理由</th>
                                <th>申请人</th>
                                <th>申请时间</th>
                                <th>状态</th>
                                <th>审批人</th>
                                <th>审批时间</th>
                                <th>审批备注</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>

        <input id="hfLogInfo" type="hidden" value="删除了一条数据" />
        <input id="hfModular" type="hidden" value="申请审核" />
        <input id="hfPageUrl" type="hidden" value="<%=Request.Url.PathAndQuery %>" />

        <div id="dJson" style="display: none;"><%=GetJsonData() %></div>
    </div>
</form>
@section scripts{
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>

    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/layer/layer.min.js"></script>
    <script src="/js/store.js"></script>
    <script src="/js/verification.js"></script>
    <script src="/js/zuiCode.js"></script>

    <script type="text/javascript">
        $(function () {
            var tabHeight = document.documentElement.clientHeight - 100;
            $('#tabData').bootstrapTable({
                height: tabHeight,
                data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                dataType: "json",
                columns: [
                    { align: 'center', width: "50px", checkbox: true },
                    { field: 'FileNo', align: 'center', width: "180px", sortable: true },
                    { field: 'ApplyDays', align: 'center', width: "50px", sortable: true },
                    { field: 'ApplyReason', align: 'left' },
                    { field: 'UserName', align: 'center', width: "100px", sortable: true },
                    { field: 'cAddTime', align: 'center', width: "150px", sortable: true },
                    { align: 'center', width: "80px", sortable: true, formatter: operateFormatter2 },
                    { field: 'ApproverName', align: 'center', width: "120px", sortable: true },
                    { field: 'cApprovalTime', align: 'center', width: "150px", sortable: true },
                    { field: 'Remarks', align: 'left', width: "150px" },
                    { align: 'center', width: "120px", formatter: operateFormatter }
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                pageSize: 100,//分页条数
                clickToSelect: false,//设置true将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "FilesApplyApplyList",//cookie键值
                pagination: true,//是否分页
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: true,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: false,//是否显示行间隔色
                onDblClickRow: function (row, obj) { //双击行事件
                    window.top.showFullPage("图像阅读器（" + (row.FileNo) + "）", "/See.aspx?FID=" + row.FID);
                },
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            var str = "<span class=\"bg-yellow\">" + text + "</span>";
                            var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).text().replaceAll(text, str);
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                        })
                    }
                }
            });
        })

        function operateFormatter(value, row, index) {
            if (row.State == "0") {
                return [
                    "<a title=\"审核\" class=\"text-success\" href=\"javascript:;\" onclick=\"ApplyEdit('" + (row.ID) + "')\">审核</a>&emsp;" +
                    "<a title=\"删除\" class=\"text-danger\" href=\"javascript:;\" onclick=\"ApplyDel('" + (row.ID) + "')\">删除</a>"
                ];
            } else {
                return [
                    "<span>-</span>"
                ];
            }
        }

        function operateFormatter2(value, row, index) {
            if (row.State == "0")
                return ["<span class=\"label label-default\">待审核<span>"];
            else if (row.State == "1")
                return ["<span class=\"label label-success\">已通过<span>"];
            else if (row.State == "2")
                return ["<span class=\"label label-warning\">不通过<span>"];
            else if (row.State == "3")
                return ["<span class=\"label label-danger\">已过期<span>"];
        }

        //编辑
        function ApplyEdit(_ApplyID) {
            //判断该申请是否能够修改  只有待审核的申请才能修改
            $.ajax({
                type: "post",
                url: "/ashx/FilesApply.ashx",
                dataType: "json",
                async: true,
                data: { type: "IsUpdate", ApplyID: _ApplyID },
                success: function (msg) {
                    if (msg.result == 1) {
                        showPage("阅卷申请审核", "/FilesApply/ApplyApproval.aspx?ID=" + _ApplyID, 500, 600, true);
                    }
                }
            });
        }

        //删除
        function ApplyDel(_ApplyID) {
            //判断改申请是否能删除 只有待审核的申请才能删除
            _Confirm('确定要删除这条数据？', function () {
                $.ajax({
                    type: "post",
                    url: "/ashx/FilesApply.ashx",
                    dataType: "json",
                    async: true,
                    data: { type: "IsUpdate", ApplyID: _ApplyID },
                    success: function (msg) {
                        if (msg.result == 1) {
                            DelDataReal("TFilesApply", _ApplyID);

                            var _LogInfo = $("#hfLogInfo").val();
                            var _Modular = $("#hfModular").val();
                            var _PageUrl = $("#hfPageUrl").val();
                            AddLog(_LogInfo, _Modular, _PageUrl);
                        }
                        else {
                            showTip("只有待审核的申请才能删除!", 2, 0);
                        }
                    }
                });
            })
        }

        //批量审核
        function ApprovalAll() {
            var ApplyList_FIDS = "";
            $.map($('#tabData').bootstrapTable('getSelections'), function (row) {
                if (ApplyList_FIDS == "") {
                    ApplyList_FIDS += row.ID;
                }
                else {
                    ApplyList_FIDS += "," + row.ID;
                }
            });

            if (ApplyList_FIDS != "") {
                store.set("ApplyList_FIDS", ApplyList_FIDS);
                showPage("阅卷申请批量审核", "/FilesApply/Approval.aspx", 450, 340, true);
            }
        }
    </script>
}
